# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-zed
_pkgname=zed
pkgver=3.1.0
pkgrel=2
pkgdesc="Abstract engine for text edition in OCaml"
url="https://github.com/ocaml-community/zed"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-3-Clause"
depends="
	ocaml-runtime
	ocaml-camomile
	ocaml-charinfo_width
	ocaml-react
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-camomile-dev
	ocaml-charinfo_width-dev
	ocaml-react-dev
	"
makedepends="$depends_dev dune ocaml"
options="!check"  # no tests provided
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-community/zed/archive/$pkgver.tar.gz
	use-built-in-result-lib.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
d4457af15f970adb7b1ed543017e590fa0ecc47171d6dd520a1397f21ce0219caa30a9db7bedb76c0602d4f6d0f0684012cc33feafe18b848d3261a460dea10a  ocaml-zed-3.1.0.tar.gz
03655451e382d7539589ef80a97e1e16edb6f269bbf95b5997c334f08dad0332807588dc9cb5b1e4aebee64c88fcd8d1d5015bdec044093dff19bbffa84b3b53  use-built-in-result-lib.patch
"
